﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy2_2
{
    public partial class txtResult : Form
    {
        public txtResult()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click_1(object sender, EventArgs e)
        {

        }

        private void button1_Click_2(object sender, EventArgs e)
        {
            // 1. 从 textBox1 取摄氏温度（字符串转 double）
            if (double.TryParse(textBox1.Text, out double celsius))
            {
                // 2. 用公式 F = (9.0 / 5) * C + 32 计算华氏温度
                double fahrenheit = (9.0 / 5) * celsius + 32;
                // 3. 显示结果到只读 TextBox
                textBox.Text = $"{celsius} 摄氏度 = {fahrenheit:F2} 华氏度";
            }
            else
            {
                // 输入非法时提示
                MessageBox.Show("请输入有效的摄氏温度数值！");
            }
        }
    }
}
